//
//  UtilsMacros.h
//  ThailandBus
//
//  Created by lantaiyuan on 16/7/19.
//  Copyright © 2016年 lantaiyuan. All rights reserved.
//

#ifndef UtilsMacros_h
#define UtilsMacros_h

#ifdef DEBUG
#define NSLog(...) NSLog(@"%s 第%d行 \n %@\n\n",__func__,__LINE__,[NSString stringWithFormat:__VA_ARGS__])
#else
#define NSLog(...)

#endif

//System version utils

#define SYSTEM_VERSION_EQUAL_TO(v)                  ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedSame)
#define SYSTEM_VERSION_GREATER_THAN(v)              ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedDescending)
#define SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(v)  ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedAscending)
#define SYSTEM_VERSION_LESS_THAN(v)                 ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedAscending)
#define SYSTEM_VERSION_LESS_THAN_OR_EQUAL_TO(v)     ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedDescending)


// 弱引用/强引用
#define WeakSelf(type)  __weak typeof(type) weak##type = type;
#define StrongSelf(type)  __strong typeof(type) type = weak##type;

#define IsNilOrNull(_ref)   (((_ref) == nil) || ([(_ref) isEqual:[NSNull null]]))

#define IsPortrait ([UIApplication sharedApplication].statusBarOrientation == UIInterfaceOrientationPortrait || [UIApplication sharedApplication].statusBarOrientation == UIInterfaceOrientationPortraitUpsideDown)
// 角度转换弧度
#define DegreesToRadian(x) (M_PI * (x) / 180.0)

// 弧度转换角度
#define RadianToDegrees(radian) (radian*180.0)/(M_PI)

// 设置 view 圆角和边框
#define ViewBorderRadius(View, Radius, Width, Color)\
\
[View.layer setCornerRadius:(Radius)];\
[View.layer setMasksToBounds:YES];\
[View.layer setBorderWidth:(Width)];\
[View.layer setBorderColor:[Color CGColor]]

// 获取系统时间戳
#define getCurentTime [NSString stringWithFormat:@"%ld", (long)[[NSDate date] timeIntervalSince1970]]

// 弱引用
#define WEAKSELF __weak typeof(self) weakSelf = self;

// 关闭键盘
#define HIDE_KEYBOARD [[UIApplication sharedApplication].keyWindow endEditing:YES];

// 用户经度
#define USER_LONGITUDE @"user_logitude"

// 用户纬度
#define USER_LATITUDE @"user_latitude"

// 微信号
#define WX_NAME @"wx_name"

#define SERVER_TEL @"0755-26968718"

// 定位城市
#define LOCATION_CITY @"location_city"
#define CityCode @"currentCityCode"//城市编码

//  用户ID
#define USER_ID @"user_id"
//唯一标示
#define Device_uuid @"uuid"

// 用户名
#define USER_NAME @"user_name"

#define Current_Device @"current_device"
#define adCode @"current_adcode"
#define Channel_ID @"contactChannel"
//钱包余额
#define Balance @"balance"

#define TOKEN_KEY @"token"
#define Invaild_KEY @"invaildDate"
// 是否冻结
#define Frozen @"frozen"

#define AppLanguage @"appLanguage"

#define CustomLocalizedString(key, comment)\
[[NSBundle bundleWithPath:[[NSBundle mainBundle] pathForResource:[NSString stringWithFormat:@"%@",[[NSUserDefaults standardUserDefaults] objectForKey:@"appLanguage"]] ofType:@"lproj"]] localizedStringForKey:(key) value:@"" table:nil]
#endif
